﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.PowerShell;
using System.Management.Automation;
using System.Security;
using AutocompleteDemo;

namespace AutocompleteDemo.Cmdlet
{
    [Cmdlet(VerbsCommon.Get, "AutoCompletionServiceApplication")]
    public sealed class GetAutoCompletionServiceApplication : SPGetCmdletBase<AutoCompletionServiceApplication>
    {
        // Fields
        private AutoCompletionServiceApplicationPipeBind m_pipeBind;
        internal const string SomeProperty = "SomeProperty";


        // Methods
        protected override void InternalValidate()
        {
            base.InternalValidate();
        }

        protected override IEnumerable<AutoCompletionServiceApplication> RetrieveDataObjects()
        {
            if (this.Identity != null)
            {
                base.DataObject = this.Identity.Read();
            }
            List<AutoCompletionServiceApplication> list = new List<AutoCompletionServiceApplication>();
            if (base.DataObject == null)
            {

                list = AutoCompletionService.Local.GetApplications();

                return list;
            }
            list.Add(base.DataObject);
            return list;
        }

        // Properties
        [Parameter(Mandatory = false, ValueFromPipeline = true, Position = 0)]
        public AutoCompletionServiceApplicationPipeBind Identity
        {
            get
            {
                return this.m_pipeBind;
            }
            set
            {
                this.m_pipeBind = value;
            }
        }
    }


}
